Page({
  data: {
    array:[],
    array2:[],
    background: [
      {"imageUrl":"http://tiyi.oss-cn-beijing.aliyuncs.com/test/20190717/64be8d9fbc4a43ccb1e82e93d27c0ba2.jpg"}, 
      {"imageUrl":"http://tiyi.oss-cn-beijing.aliyuncs.com/test/20190417/88032fe0321f4caba986ff486f74cd72.jpg"}, 
      {"imageUrl":"http://tiyi.oss-cn-beijing.aliyuncs.com/test/20190328/513230f97a8a4bf784aedb85be52e61d.jpg"}
      ],
    indicatorDots: true,
    autoplay: true,
    vertical: false,
    interval: 3000,
    circular: false,

  },
  onLoad(){
    //版本更新检测
    const updateManager = my.getUpdateManager()

    updateManager.onCheckForUpdate(function (res) {
      // 请求完新版本信息的回调
      console.log(res.hasUpdate)
    })

    updateManager.onUpdateReady(function () {
      my.confirm({
        title: '更新提示',
        content: '新版本已经准备好，是否重启应用？',
        success: function (res) {
          if (res.confirm) {
            // 新的版本已经下载好，调用 applyUpdate 应用新版本并重启
            updateManager.applyUpdate()
          }
        }
      })
    })

    updateManager.onUpdateFailed(function () {
      // 新版本下载失败
    })

  },
  onShow(){
     let that = this;
      my.showLoading({
        content: '加载中...'
      });
        //请求数据
      my.request({
      url: 'https://tiyi.site/seaHorse/app/draw/drawUrlList',
      method: 'POST',
      data: {},
      dataType: 'json',
      success: function(res) {
        that.setData({
          array:res.data.result.ramList,
          array2:res.data.result.newList
        })
      },
      fail: function(res) {
        my.alert({content: 'fail:'+res});
      },
      complete: function(res) {
        my.hideLoading();
      }
      });
  },

  onTap(e) {
  
     my.previewImage({
      current:  e.currentTarget.dataset.index, // 当前显示图片的 http 链接
      urls: this.data.array,
    });
   
  },
  onNewTap(e) {
    
     my.previewImage({
      current:  e.currentTarget.dataset.index, // 当前显示图片的 http 链接
      urls: this.data.array2,
    });
   
  },
  //风景
  scenery(){
    my.navigateTo({
    url: '/pages/draw-type/draw-type?type=1'
  })
  },
  //人文
  humanity(){
    my.navigateTo({
    url: '/pages/draw-type/draw-type?type=2'
  })
  },
  //美食
  food(){
    my.navigateTo({
    url: '/pages/draw-type/draw-type?type=3'
  })
  },
  //地图
  map(){
    my.navigateTo({
    url: '/pages/draw-type/draw-type?type=4'
  })
  },
  //物产
  products(){
    my.navigateTo({
    url: '/pages/draw-type/draw-type?type=5'
  })
  },
  toMore(){
     my.navigateTo({
     url: '/pages/draw-type/draw-type?type=1'
  })
  },
  onSearchBarTap() {
    
    my.navigateTo({
    url: '/pages/common/search/search?type=search',
    });
  },
  onReachBottom() {
    // 页面被拉到底部
     console.log("页面被拉到底部")
  },
});
